#-*- coding: utf-8 -*-
from django.shortcuts import render, render_to_response, redirect
from django.conf import settings 
from scm_auth.forms import *
from scm_auth.models import *
from django.http import HttpResponse
from django.template.response import TemplateResponse


def create_account(request):
    form= ProfilF()
    return render(request, 'create_account.html', locals())


def save_account(request):
    if request.method == 'POST':
        form = ProfilF(request.POST)
        if form.is_valid():
            p = Profil()    
            a = ApiAccount()
            a.create_account(form.cleaned_data['accountName'], form.cleaned_data['keyID'], form.cleaned_data['vCode'])
            p.create_profil(form.cleaned_data['username'], form.cleaned_data['firstname'], form.cleaned_data['lastname'], form.cleaned_data['email'], form.password, a)
#             p.username = form.cleaned_data['username']
#             p.firstname = form.cleaned_data['firstname']
#             p.lastname = form.cleaned_data['lastname']
#             p.email = form.cleaned_data['email']
            #emailCheck = forms.EmailField(label='Email-check', required = True)
#             p.password = form.password
            #passwordCheck = forms.PasswordInput(label='Password-check', required = True)
#             p.save()
            
#             a.accountName = form.cleaned_data['accountName']
#             a.keyID = form.cleaned_data['keyID']
#             a.vCode = form.cleaned_data['vCode']
#             a.save()
            
    return redirect('eve_scm.views.scm_home')
    